IDEA 2020 配置 Maven 创建 Spring Boot 项目 |
您所在的位置:网站首页 › idea新建spring boot › IDEA 2020 配置 Maven 创建 Spring Boot 项目 |
文章目录
Maven安装配置 Maven配置 Maven 仓库(仓库路径、阿里云下载)IDEA 配置 Maven
IDEA 创建 springboot 项目
在新电脑上配环境总是要不停的百度,简单记录一下。。。 Maven 安装配置 Maven前提:已经安装好 Java 运行环境,否则配置不能成功; cmd 输入 java -version 可以看到 java 版本号再做下面的; 这里下载各个版本的Maven:http://archive.apache.org/dist/maven/maven-3/ 根据 SpringBoot 官网文档,Mave 版本需要 3.3 及以上; ![]() cmd 里输入:mvn -v;提示如下则配置成功; 所谓的仓库就是用于存放项目需要的 jar 包的,只要配好一个仓库,以后的项目都可以去使用这个仓库里的 jar 包。 配置仓库位置:打开 Maven 根目录下的 conf/setting.xml; 配置阿里云下载:还是在 Maven 根目录下的 conf/setting.xml; Ctrl + F 搜索 ,在 下新加一个阿里云的镜像地址: alimaven central aliyun maven http://maven.aliyun.com/nexus/content/repositories/central/
打开 IDEA,点击开始右下角的 Configure -> Settings 进入设置; 设置界面:Build, Execute, Deployment->Build Tools->Maven; 修改 Maven home directory: D:\JavaDevelop\Maven\apache-maven-3.5.0 修改 User settings file: D:\JavaDevelop\Maven\apache-maven-3.5.0\conf\settings.xml 只要 settings.xml 中配置的正确,Local repository 会被自动识别到; 打开 IDEA,Create New Project,选择 Maven 项目,勾选 Create from archetype,选中 maven-archetype-webapp; 如果右下角跳出选项,选择 Auto Enable; 首先 pom.xml 中引入项目依赖: 这些是随时会更新的,建议去看 springboot官方文档; org.springframework.boot spring-boot-starter-parent 2.2.5.RELEASE org.springframework.boot spring-boot-starter-web junit junit 4.11 test将 springboot 配置成标准目录结构: helloController.java: package com.yusael.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/hello") public class helloController { @GetMapping("/hello") public String hello() { System.out.println("hello springboot!!!"); return "hello springboot"; } }点击运行:成功跑起 spring boot 。 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |